package com.woniuxy.empserver.controller;

import com.woniuxy.empserver.entity.TDept;
import com.woniuxy.empserver.entity.TManager;
import com.woniuxy.empserver.servcie.DeptService;
import com.woniuxy.empserver.vo.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("dept")
public class DeptController {

    @Autowired
    DeptService deptService ;

    @GetMapping("/list")
    public ResponseResult<List<TDept>> list(){
        ResponseResult<List<TDept>> result = new ResponseResult<>();
        try {
            List<TDept> all = deptService.findAll();
            result.setCode(200);
            result.setMsg("查询成功!");
            result.setData(all);
        }catch (Exception e) {
            e.printStackTrace();
            result.setMsg("系统错误，请联系管理员!");
            result.setCode(203);
        }
        return result ;
    }

}
